#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
@author:stone
@file:gitee.py
@time:2021/08/12
"""
from common.config import Config
from common.net import Net


class Gitee:
    conf = None

    def __init__(self):
        self.conf = Config()

    def getRepoBySearch(self, query_word, page, per_page, order):
        headers = {"Content-Type": "application/json;charset=UTF-8"}

        token = "access_token=" + self.conf.gitee_token
        query_word = "q=" + query_word
        page = "page=" + page
        per_page = "per_page=" + per_page
        order = "order=" + order
        url = """https://gitee.com/api/v5/search/repositories"""
        url += "?" + token
        url += "&" + query_word
        url += "&" + page
        url += "&" + per_page
        url += "&" + order
        n = Net()
        return n.send(url, headers, "get", "")
